﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System.ComponentModel;
using System.Web.UI;

namespace Mobile.WebControls.Field
{
    public class Field : Div
    {
        #region Members
        private Label label;
        #endregion

        #region Properties
        [Category("Appearance")]
        public string LabelText { get; set; }
        #endregion

        #region Methods
        protected void SetLabelForControlId(string forId)
        {
            if (label != null)
            {
                label.ForId = forId;
            }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            label = new Label { Text = LabelText };
            Controls.Add(label);
        }
        #endregion

        #region Render Methods

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(MetadataAttribute.DataRole, DataRole.Fieldcontain);
        }
        #endregion
    }
}
